home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group92c.txt / 000012_icon-group-sender _Tue Oct 6 13:12:00 1992.msg < prev    next >
Internet Message Format  |  1993-01-04  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 6 Oct 1992 10:22:54 MST
  2. Date: Tue, 6 Oct 92 13:12:00 EDT
  3. From: Paul_Abrahams@MTS.cc.Wayne.edu
  4. To: icon-group@cs.arizona.edu
  5. Message-Id: <508918@MTS.cc.Wayne.edu>
  6. Subject: Logging out from Unix using an Icon program
  7. Status: R
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9.  
  10. Chris Tenaglia asks:
  11.  
  12. > If I have a simple abc menu that looks something like :
  13. >           M : MAIL
  14. >           C : CHANGE PASSWORD
  15. >           L : LOGOUT
  16. > Is there a way to log out cleanly. Unix seems to pop processes out all over
  17. > the place. I use icon 8.7 under ultrix 4.2a. My background is chiefly VMS.
  18. > There's probably a real simple answer I can't see because of my background.
  19.  
  20. I haven't been following all the replies to this question closely, but I've
  21. noticed several suggestions for using 'kill'.  That seems to me to be a
  22. meat-cleaver approach.
  23.  
  24. I'll assume that the context is that you're writing an Icon program to
  25. serve as a replacement login shell.  (In non-Unixspeak, you're writing
  26. an Icon program that takes over when a user logs in and enables the user
  27. to carry out operations such as reading mail, changing hisorher password,
  28. and eventually logging out.)
  29.  
  30. Under this assumption, there *is* a simple answer: call the program from
  31. your initialization file (.profile for the Bourne or Korn shells, .cshrc
  32. for the C shell) using the 'exec' command.  The program will then replace
  33. the executing shell as your outermost process.  When you exit from the
  34. Icon program, you'll also log out.  Therefore, just tie the 'L' item in
  35. your menu to the Icon 'exit' function.
  36.  
  37. Another strategy is to use a Bourne shell function or the C shell 'source'
  38. command with a little script that tests the exit code of the Icon program
  39. and does an exit if that code has a certain distinguished value.  However,
  40. I don't know of any advantages that this method has over the simple one.
  41. Direct execution as provided by Bourne shell functions and C shell 'source'
  42. is essential; if you try this from a shell script, you'll merely exit
  43. from the script.
  44.  
  45. Unix makes it very difficult to log out from a nested shell, deliberately
  46. so.  You have to find your top-level process and kill it.  I assume that
  47. for your purposes you don't have to log out from a nested shell.
  48.  
  49. Paul Abrahams
  50.  
  51.  
  52.  
  53.